<template>
	<view class="flex-col homepage">
		<view class="wrapper">
			<view class="u-line-1 text">最多可添加5位住院人</view>
		</view>
		<view @click="message(inp.id)" class="flex-col wrapper-two" v-for="inp in inpatients" :key="inp.id">
			<!-- <view> -->
			<view class="flex-row wraper-row">
				<view class="u-line-1 text-two">{{inp.thePatient.name}}</view>
				<text v-if="inp.status == '住院中'">
					<view style="color: aquamarine; font-size: 16px;">住院中</view>
				</text>
				<text v-if="inp.status == '已出院'">
					<view style="color: aquamarine; font-size: 16px;">已出院</view>
				</text>

			</view>
			<view class="u-line-1 text-three">住院号</view>
			<view class="u-line-1 text-four">就诊卡号</view>
			<view class="u-line-1 text-five">入院时间</view>
			<view class="u-line-1 text-six">出院时间</view>
			<view class="u-line-1 text-seven">{{inp.admissionNumber}}</view>
			<view class="u-line-1 text-eight">{{inp.thePatient.hospitalNumber}}</view>
			<view class="u-line-1 text-nine">{{inp.hospitalizedTime}}</view>
			<view class="u-line-1 text-ten">{{inp.leavehospitalTime}}</view>
			<!-- </view> -->
		</view>
		<view>
			<u-button class="button" @click="binding">
				绑定新的住院号
			</u-button>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				userId: '',
				URL: 'http://localhost:9000/', //主域名
				inpatients: []
			}
		},
		methods: {

			//住院人信息i
			message(id) {
				console.log(id)
				uni.navigateTo({
					url: "hospitalView?id=" + id
				})
			},

			//绑定新的住院号
			binding() {
				console.log(this.userId)
				uni.navigateTo({
					url: "bindPatient?id=" + this.userId
				})
			}
		},
		onLoad(id) {
			this.userId = id.id
			uni.request({
				url: this.URL + "user/user/inpatient/inpatientUserId/" + this.userId,
				method: "GET",
				success: (res) => {
					console.log(res)
					if (res.data.code == 20000) {
						this.inpatients = res.data.data.inpatients
						console.log(this.inpatients)
					}
				}
			})
			console.log(this.userId)
		}
	}
</script>
<style lang="scss" scoped>
	/** 全局样式-开始,建议放在公共css样式文件中,比如common.css 或app.vue文件 */

	html,
	body {
		margin: 0;
		width: 100%;
		height: 100%;
		font-size: 16px
	}

	view,
	text,
	image {
		position: relative;
		box-sizing: border-box;
		flex-shrink: 0;
	}

	.flex-col {
		display: flex;
		align-items: flex-start;
		flex-direction: column;
	}

	.flex-row {
		display: flex;
		align-items: flex-start;
	}

	.flex-col .flex-row {
		width: 100%
	}

	/** 全局样式-结束*/

	.homepage {
		height: 1334rpx;

		.wrapper {
			width: 100%;
			margin-bottom: 32rpx;
			padding: 22rpx 0rpx 18rpx 46rpx;
			background: #fbf1e9;

			.text {
				width: 100%;
				font-size: 24rpx;
				font-weight: 545;
				color: #ff8838;
			}
		}

		.wrapper-two {
			width: 706rpx;
			margin-right: auto;
			margin-bottom: 80rpx;
			margin-left: auto;
			padding: 52rpx 0rpx 24rpx 36rpx;
			border-radius: 10rpx;
			background: #f5f9ff;

			.wraper-row {
				width: 596rpx;
				justify-content: space-between;
				margin-bottom: 28rpx;

				.text-two {
					width: 138rpx;
					font-size: 32rpx;
				}

				.tag {
					background: #c5efe6;
					color: #03ca82;
				}
			}

			.text-three {
				width: 128rpx;
				margin-bottom: 20rpx;
				letter-spacing: 12rpx;
				font-size: 28rpx;
				color: rgba(194, 194, 194, 1);
			}

			.text-four {
				width: 128rpx;
				margin-bottom: 20rpx;
				font-size: 28rpx;
				color: rgba(194, 194, 194, 1);
			}

			.text-five {
				width: 128rpx;
				margin-bottom: 20rpx;
				font-size: 28rpx;
				color: rgba(194, 194, 194, 1);
			}

			.text-six {
				width: 128rpx;
				font-size: 28rpx;
				color: rgba(194, 194, 194, 1);
			}

			.text-seven {
				width: 532rpx;
				top: 132rpx;
				right: -16rpx;
				font-size: 28rpx;
				position: absolute;
			}

			.text-eight {
				width: 532rpx;
				bottom: 140rpx;
				right: -16rpx;
				font-size: 28rpx;
				position: absolute;
			}

			.text-nine {
				width: 532rpx;
				bottom: 82rpx;
				right: -16rpx;
				font-size: 28rpx;
				position: absolute;
			}

			.text-ten {
				width: 532rpx;
				bottom: 24rpx;
				right: -16rpx;
				font-size: 28rpx;
				position: absolute;
			}
		}

		// .button {
		//     width: 706rpx;
		//     display: block;
		//     margin-right: auto;
		//     margin-left: auto;
		//     background: #006eff;
		//     color: #ffffff;
		// }

		.button {
			width: 694rpx;
			height: 90rpx;
			display: block;
			margin-right: auto;
			margin-left: auto;
			font-size: 36rpx;
			background: #006eff;
			color: #ffffff;
		}
	}
</style>
